﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace Transport.Admin
{
    public partial class TraCuuLich : System.Web.UI.Page
    {
        TaiXeControl txCtrl;
        protected void Page_Load(object sender, EventArgs e)
        {
            try
            {
                txCtrl = new TaiXeControl();
                List<LichDTO> ls = txCtrl.getSchedule(txt_ID.Text);

                if (txt_Begin.Text != "" && txt_End.Text != "")
                {
                    DateTime begin = DateTime.Parse(txt_Begin.Text);
                    DateTime end = DateTime.Parse(txt_End.Text);

                    for (int i = ls.Count - 1; i >= 0; i--)
                    {
                        if (!(ls[i].TuNgay <= begin && ls[i].DenNgay >= begin || ls[i].TuNgay <= end && ls[i].DenNgay >= end))
                        {
                            ls.RemoveAt(i);
                        }
                    }
                }

                lb_Test.Text = ls.Count.ToString();

                GridView_Lich.DataSource = ls;
                GridView_Lich.DataBind();
            }
            catch (Exception)
            {

            }
        }
    }
}